#pragma once

#include <string>
#include <cstdlib>
#include <cstdio>
#include <cerrno>
#include <stdarg.h>

#include <iostream>
#include <fstream>

using namespace std;

#include "cvtclass_common.hpp"
#include "cvtclass_parser.hpp"

#define gen_format_write(stream,fmt, ...) \
    {\
        char sbuf[maxBuffSize] = { 0 }; \
        format_args(sbuf,fmt,##__VA_ARGS__);\
        if(stream.is_open()){\
            stream << sbuf << endl;\
        } else {\
            std::cout << sbuf << endl;\
        }\
    }


class CVTPkt_Gener
{
public:
    CVTPkt_Gener(const string& sClassName) : m_className(sClassName) {};
    ~CVTPkt_Gener() = default;

    int CVTClass_execute(const Object& object);
private:
    int CVTClass_var_define(const Object& object);
    int CVTClass_function_convert_define(const Object& object);
    int CVTClass_function_set_define(const Object& object);
    int CVTClass_function_get_define(const Object& object);

    int CVTClass_function_convert_imp(const Object& object);
    int CVTClass_function_set_imp(const Object& object);
    int CVTClass_function_get_imp(const Object& object);
    int CVTClass_gen_hpp(const Object& object);
    int CVTClass_gen_cpp(const Object& object);    
private:
    string m_className;
    ofstream m_hppstream;
    ofstream m_cppstream;
};